#!opentype

languagesystem DFLT dflt;
languagesystem dev2 dflt;
languagesystem deva dflt;

table head {
  FontRevision 1.000;
} head;

include (../../family_classes.fea);
include (../../family_tables.fea);
include (../../family_extension.fea);


# --------------
# Localized Form
# --------------

# attempt to add marathi

 feature locl {
  script dev2;
  language MAR;
    sub dvSHA by dvSHA.mar;
    sub dvLA by dvLA.mar;

  script deva;
  language MAR;
    sub dvSHA by dvSHA.mar;
    sub dvLA by dvLA.mar;
 } locl;


# ----------
# Nukta Form
# ----------

feature nukt {
  sub dvKA   dvNukta by dvKxA;
  sub dvKHA  dvNukta by dvKHxA;
  sub dvGA   dvNukta by dvGxA;
  sub dvJA   dvNukta by dvJxA;
  sub dvDDA  dvNukta by dvDDxA;
  sub dvDDHA dvNukta by dvDDHxA;
  sub dvPHA  dvNukta by dvPHxA;
  sub dvRA   dvNukta by dvRxA;
} nukt;


# ---------------
# Akhand Ligature
# ---------------

feature akhn {

  script DFLT;

    lookup akhn_shared {
      sub dvKA dvVirama dvSSA by dvK_SSA;
      sub dvJA dvVirama dvNYA by dvJ_NYA;
    } akhn_shared;

    lookup akhn_dev2 {
      sub dvRA' dvVirama' zerowidthjoiner by dvEyelash;
    } akhn_dev2;

  script dev2;
    lookup akhn_shared;
    lookup akhn_dev2;

  script deva;
    lookup akhn_shared;

} akhn;


# ---------
# Reph Form
# ---------

feature rphf {
  sub dvRA dvVirama by dvReph;
} rphf;


# ----------
# Rakar Form
# ----------

feature rkrf {

  script DFLT;
    lookup rkrf_dev2 {

    # sub dvK_SSA dvVirama dvRA by dvK_SS_RA;
    # sub dvJ_NYA dvVirama dvRA by dvJ_NY_RA;

      sub dvKA   dvVirama dvRA by   dvK_RA;
      sub dvKHA  dvVirama dvRA by  dvKH_RA;
      sub dvGA   dvVirama dvRA by   dvG_RA;
      sub dvGHA  dvVirama dvRA by  dvGH_RA;
      sub dvNGA  dvVirama dvRA by  dvNG_RA;
      sub dvCA   dvVirama dvRA by   dvC_RA;
      sub dvCHA  dvVirama dvRA by  dvCH_RA;
      sub dvJA   dvVirama dvRA by   dvJ_RA;
      sub dvJHA  dvVirama dvRA by  dvJH_RA;
      sub dvNYA  dvVirama dvRA by  dvNY_RA;
      sub dvTTA  dvVirama dvRA by  dvTT_RA;
      sub dvTTHA dvVirama dvRA by dvTTH_RA;
      sub dvDDA  dvVirama dvRA by  dvDD_RA;
      sub dvDDHA dvVirama dvRA by dvDDH_RA;
      sub dvNNA  dvVirama dvRA by  dvNN_RA;
      sub dvTA   dvVirama dvRA by   dvT_RA;
      sub dvTHA  dvVirama dvRA by  dvTH_RA;
      sub dvDA   dvVirama dvRA by   dvD_RA;
      sub dvDHA  dvVirama dvRA by  dvDH_RA;
      sub dvNA   dvVirama dvRA by   dvN_RA;
      sub dvPA   dvVirama dvRA by   dvP_RA;
      sub dvPHA  dvVirama dvRA by  dvPH_RA;
      sub dvBA   dvVirama dvRA by   dvB_RA;
      sub dvBHA  dvVirama dvRA by  dvBH_RA;
      sub dvMA   dvVirama dvRA by   dvM_RA;
      sub dvYA   dvVirama dvRA by   dvY_RA;
    # sub dvRA   dvVirama dvRA by   dvR_RA; # Reph
      sub dvLA   dvVirama dvRA by   dvL_RA;
      sub dvVA   dvVirama dvRA by   dvV_RA;
      sub dvSHA  dvVirama dvRA by  dvSH_RA;
      sub dvSSA  dvVirama dvRA by  dvSS_RA;
      sub dvSA   dvVirama dvRA by   dvS_RA;
      sub dvHA   dvVirama dvRA by   dvH_RA;
      sub dvLLA  dvVirama dvRA by  dvLL_RA;

      sub dvKxA  dvVirama dvRA by  dvKx_RA;
      sub dvKHxA dvVirama dvRA by dvKHx_RA;
      sub dvGxA  dvVirama dvRA by  dvGx_RA;
      sub dvJxA  dvVirama dvRA by  dvJx_RA;
      sub dvPHxA dvVirama dvRA by dvPHx_RA;

    } rkrf_dev2;

  script dev2;
    lookup rkrf_dev2;

} rkrf;


# ---------------
# Below-base Form
# ---------------

feature blwf {

  script DFLT;
    lookup blwf_dev2 {
      sub dvVirama dvRA by dvRashtrasign;
    } blwf_dev2;

  script dev2;
    lookup blwf_dev2;

  script deva;
    lookup blwf_deva {
      sub dvRA dvVirama by dvRashtrasign;
    } blwf_deva;

} blwf;


# --------------------
# Half (Pre-base) Form
# --------------------

feature half {

  script DFLT;

    lookup half_shared {

      sub dvK_SSA dvVirama by dvK_SS;
      sub dvJ_NYA dvVirama by dvJ_NY;

      sub dvKA   dvVirama by dvK;
      sub dvKHA  dvVirama by dvKH;
      sub dvGA   dvVirama by dvG;
      sub dvGHA  dvVirama by dvGH;
      sub dvNGA  dvVirama by dvNG;
      sub dvCA   dvVirama by dvC;
      sub dvCHA  dvVirama by dvCH;
      sub dvJA   dvVirama by dvJ;
      sub dvJHA  dvVirama by dvJH;
      sub dvNYA  dvVirama by dvNY;
      sub dvTTA  dvVirama by dvTT;
      sub dvTTHA dvVirama by dvTTH;
      sub dvDDA  dvVirama by dvDD;
      sub dvDDHA dvVirama by dvDDH;
      sub dvNNA  dvVirama by dvNN;
      sub dvTA   dvVirama by dvT;
      sub dvTHA  dvVirama by dvTH;
      sub dvDA   dvVirama by dvD;
      sub dvDHA  dvVirama by dvDH;
      sub dvNA   dvVirama by dvN;
      sub dvPA   dvVirama by dvP;
      sub dvPHA  dvVirama by dvPH;
      sub dvBA   dvVirama by dvB;
      sub dvBHA  dvVirama by dvBH;
      sub dvMA   dvVirama by dvM;
      sub dvYA   dvVirama by dvY;
      sub dvRA   dvVirama by dvEyelash;
      sub dvLA   dvVirama by dvL;
      sub dvVA   dvVirama by dvV;
      sub dvSHA  dvVirama by dvSH;
      sub dvSSA  dvVirama by dvSS;
      sub dvSA   dvVirama by dvS;
      sub dvHA   dvVirama by dvH;
      sub dvLLA  dvVirama by dvLL;

      sub dvKxA  dvVirama by dvKx;
      sub dvKHxA dvVirama by dvKHx;
      sub dvGxA  dvVirama by dvGx;
      sub dvJxA  dvVirama by dvJx;
      sub dvPHxA dvVirama by dvPHx;
      sub dvRxA  dvVirama by dvEyelash;

    } half_shared;

    lookup half_dev2 {

    # sub dvK_SS_RA dvVirama by dvK_SS_R;
    # sub dvJ_NY_RA dvVirama by dvJ_NY_R;

      sub   dvK_RA dvVirama by   dvK_R;
      sub  dvKH_RA dvVirama by  dvKH_R;
      sub   dvG_RA dvVirama by   dvG_R;
      sub  dvGH_RA dvVirama by  dvGH_R;
      sub  dvNG_RA dvVirama by  dvNG_R;
      sub   dvC_RA dvVirama by   dvC_R;
      sub  dvCH_RA dvVirama by  dvCH_R;
      sub   dvJ_RA dvVirama by   dvJ_R;
      sub  dvJH_RA dvVirama by  dvJH_R;
      sub  dvNY_RA dvVirama by  dvNY_R;
      sub  dvTT_RA dvVirama by  dvTT_R;
      sub dvTTH_RA dvVirama by dvTTH_R;
      sub  dvDD_RA dvVirama by  dvDD_R;
      sub dvDDH_RA dvVirama by dvDDH_R;
      sub  dvNN_RA dvVirama by  dvNN_R;
      sub   dvT_RA dvVirama by   dvT_R;
      sub  dvTH_RA dvVirama by  dvTH_R;
      sub   dvD_RA dvVirama by   dvD_R;
      sub  dvDH_RA dvVirama by  dvDH_R;
      sub   dvN_RA dvVirama by   dvN_R;
      sub   dvP_RA dvVirama by   dvP_R;
      sub  dvPH_RA dvVirama by  dvPH_R;
      sub   dvB_RA dvVirama by   dvB_R;
      sub  dvBH_RA dvVirama by  dvBH_R;
      sub   dvM_RA dvVirama by   dvM_R;
      sub   dvY_RA dvVirama by   dvY_R;
    # sub   dvR_RA dvVirama by   dvR_R; # Reph
      sub   dvL_RA dvVirama by   dvL_R;
      sub   dvV_RA dvVirama by   dvV_R;
      sub  dvSH_RA dvVirama by  dvSH_R;
      sub  dvSS_RA dvVirama by  dvSS_R;
      sub   dvS_RA dvVirama by   dvS_R;
      sub   dvH_RA dvVirama by   dvH_R;
      sub  dvLL_RA dvVirama by  dvLL_R;

      sub  dvKx_RA dvVirama by  dvKx_R;
      sub dvKHx_RA dvVirama by dvKHx_R;
      sub  dvGx_RA dvVirama by  dvGx_R;
      sub  dvJx_RA dvVirama by  dvJx_R;
      sub dvPHx_RA dvVirama by dvPHx_R;

    } half_dev2;

  script dev2;
    lookup half_shared;
    lookup half_dev2;

  script deva;
    lookup half_shared;

} half;


# -------------
# Vattu Variant
# -------------

feature vatu {
  script deva;

  # sub dvK_SSA dvRashtrasign by dvK_SS_RA;
  # sub dvJ_NYA dvRashtrasign by dvJ_NY_RA;

    sub dvKA   dvRashtrasign by   dvK_RA;
    sub dvKHA  dvRashtrasign by  dvKH_RA;
    sub dvGA   dvRashtrasign by   dvG_RA;
    sub dvGHA  dvRashtrasign by  dvGH_RA;
    sub dvNGA  dvRashtrasign by  dvNG_RA;
    sub dvCA   dvRashtrasign by   dvC_RA;
    sub dvCHA  dvRashtrasign by  dvCH_RA;
    sub dvJA   dvRashtrasign by   dvJ_RA;
    sub dvJHA  dvRashtrasign by  dvJH_RA;
    sub dvNYA  dvRashtrasign by  dvNY_RA;
    sub dvTTA  dvRashtrasign by  dvTT_RA;
    sub dvTTHA dvRashtrasign by dvTTH_RA;
    sub dvDDA  dvRashtrasign by  dvDD_RA;
    sub dvDDHA dvRashtrasign by dvDDH_RA;
    sub dvNNA  dvRashtrasign by  dvNN_RA;
    sub dvTA   dvRashtrasign by   dvT_RA;
    sub dvTHA  dvRashtrasign by  dvTH_RA;
    sub dvDA   dvRashtrasign by   dvD_RA;
    sub dvDHA  dvRashtrasign by  dvDH_RA;
    sub dvNA   dvRashtrasign by   dvN_RA;
    sub dvPA   dvRashtrasign by   dvP_RA;
    sub dvPHA  dvRashtrasign by  dvPH_RA;
    sub dvBA   dvRashtrasign by   dvB_RA;
    sub dvBHA  dvRashtrasign by  dvBH_RA;
    sub dvMA   dvRashtrasign by   dvM_RA;
    sub dvYA   dvRashtrasign by   dvY_RA;
  # sub dvRA   dvRashtrasign by   dvR_RA; # Reph
    sub dvLA   dvRashtrasign by   dvL_RA;
    sub dvVA   dvRashtrasign by   dvV_RA;
    sub dvSHA  dvRashtrasign by  dvSH_RA;
    sub dvSSA  dvRashtrasign by  dvSS_RA;
    sub dvSA   dvRashtrasign by   dvS_RA;
    sub dvHA   dvRashtrasign by   dvH_RA;
    sub dvLLA  dvRashtrasign by  dvLL_RA;

    sub dvKxA  dvRashtrasign by  dvKx_RA;
    sub dvKHxA dvRashtrasign by dvKHx_RA;
    sub dvGxA  dvRashtrasign by  dvGx_RA;
    sub dvJxA  dvRashtrasign by  dvJx_RA;
    sub dvPHxA dvRashtrasign by dvPHx_RA;

  # sub dvK_SS dvRashtrasign by dvK_SS_R;
  # sub dvJ_NY dvRashtrasign by dvJ_NY_R;

    sub dvK   dvRashtrasign by   dvK_R;
    sub dvKH  dvRashtrasign by  dvKH_R;
    sub dvG   dvRashtrasign by   dvG_R;
    sub dvGH  dvRashtrasign by  dvGH_R;
    sub dvNG  dvRashtrasign by  dvNG_R;
    sub dvC   dvRashtrasign by   dvC_R;
    sub dvCH  dvRashtrasign by  dvCH_R;
    sub dvJ   dvRashtrasign by   dvJ_R;
    sub dvJH  dvRashtrasign by  dvJH_R;
    sub dvNY  dvRashtrasign by  dvNY_R;
    sub dvTT  dvRashtrasign by  dvTT_R;
    sub dvTTH dvRashtrasign by dvTTH_R;
    sub dvDD  dvRashtrasign by  dvDD_R;
    sub dvDDH dvRashtrasign by dvDDH_R;
    sub dvNN  dvRashtrasign by  dvNN_R;
    sub dvT   dvRashtrasign by   dvT_R;
    sub dvTH  dvRashtrasign by  dvTH_R;
    sub dvD   dvRashtrasign by   dvD_R;
    sub dvDH  dvRashtrasign by  dvDH_R;
    sub dvN   dvRashtrasign by   dvN_R;
    sub dvP   dvRashtrasign by   dvP_R;
    sub dvPH  dvRashtrasign by  dvPH_R;
    sub dvB   dvRashtrasign by   dvB_R;
    sub dvBH  dvRashtrasign by  dvBH_R;
    sub dvM   dvRashtrasign by   dvM_R;
    sub dvY   dvRashtrasign by   dvY_R;
  # sub dvR   dvRashtrasign by   dvR_R; # Reph
    sub dvL   dvRashtrasign by   dvL_R;
    sub dvV   dvRashtrasign by   dvV_R;
    sub dvSH  dvRashtrasign by  dvSH_R;
    sub dvSS  dvRashtrasign by  dvSS_R;
    sub dvS   dvRashtrasign by   dvS_R;
    sub dvH   dvRashtrasign by   dvH_R;
    sub dvLL  dvRashtrasign by  dvLL_R;

    sub dvKx  dvRashtrasign by  dvKx_R;
    sub dvKHx dvRashtrasign by dvKHx_R;
    sub dvGx  dvRashtrasign by  dvGx_R;
    sub dvJx  dvRashtrasign by  dvJx_R;
    sub dvPHx dvRashtrasign by dvPHx_R;

} vatu;


# -------------
# Conjunct form
# -------------

# feature cjct {
# } cjct;


# ---------------------
# Pre-base Substitution
# ---------------------

feature pres {

  # EYELASH

  # If ZWJ has been filtered out (Core Text):
  sub dvEyelash dvYA by dvEyelash_YA;
  sub dvEyelash dvHA by dvEyelash_HA;

  # Else:
  sub dvEyelash zerowidthjoiner dvYA by dvEyelash_YA;
  sub dvEyelash zerowidthjoiner dvHA by dvEyelash_HA;

  # CCA

  sub dvK dvKA by dvK_KA;
  sub dvKx dvKxA by dvKx_KxA;
  sub dvK dvKHA by dvK_KHA;
  sub dvK dvCA by dvK_CA;
  sub dvK dvJA by dvK_JA;
  sub dvK dvTTA by dvK_TTA;
  sub dvK dvNNA by dvK_NNA;
  sub dvK dvTA by dvK_TA;
  sub dvKx dvTA by dvKx_TA;
  sub dvK dvT dvYA by dvK_T_YA;
  sub dvK dvT_RA by dvK_T_RA;
  sub dvK dvT dvVA by dvK_T_VA;
  sub dvK dvTHA by dvK_THA;
  sub dvK dvDA by dvK_DA;
  sub dvK dvNA by dvK_NA;
  sub dvK dvPA by dvK_PA;
  sub dvK dvP_RA by dvK_P_RA;
  sub dvK dvPHA by dvK_PHA;
  sub dvKx dvPHA by dvKx_PHA;
  sub dvKx dvPHxA by dvKx_PHxA;
  sub dvKx dvBA by dvKx_BA;
  sub dvK dvMA by dvK_MA;
  sub dvKx dvMA by dvKx_MA;
  sub dvK dvYA by dvK_YA;
  sub dvK dvLA by dvK_LA;
  sub dvK dvVA by dvK_VA;
  sub dvK dvV dvYA by dvK_V_YA;
  sub dvK dvSHA by dvK_SHA;
  sub dvK_SS dvMA by dvK_SS_MA;
  sub dvK_SS dvM dvYA by dvK_SS_M_YA;
  sub dvK_SS dvYA by dvK_SS_YA;
  sub dvK_SS dvVA by dvK_SS_VA;
  sub dvK dvSA by dvK_SA;
  sub dvK dvS dvTTA by dvK_S_TTA;
  sub dvK dvS dvDDA by dvK_S_DDA;
  sub dvK dvS dvTA by dvK_S_TA;
  sub dvK dvS dvP_RA by dvK_S_P_RA;
  sub dvK dvS dvP dvLA by dvK_S_P_LA;

  sub dvKH dvKHA by dvKH_KHA;
  sub dvKH dvTA by dvKH_TA;
  sub dvKHx dvTA by dvKHx_TA;
  sub dvKH dvNA by dvKH_NA;
  sub dvKH dvMA by dvKH_MA;
  sub dvKHx dvMA by dvKHx_MA;
  sub dvKH dvYA by dvKH_YA;
  sub dvKHx dvYA by dvKHx_YA;
  sub dvKH dvVA by dvKH_VA;
  sub dvKHx dvVA by dvKHx_VA;
  sub dvKH dvSHA by dvKH_SHA;
  sub dvKHx dvSHA by dvKHx_SHA;
  sub dvKHx dvSA by dvKHx_SA;

  sub dvG dvGA by dvG_GA;
  sub dvG dvGHA by dvG_GHA;
  sub dvG dvJA by dvG_JA;
  sub dvG dvNNA by dvG_NNA;
  sub dvG dvDA by dvG_DA;
  sub dvG dvDHA by dvG_DHA;
  sub dvG dvDH dvYA by dvG_DH_YA;
  sub dvG dvDH dvVA by dvG_DH_VA;
  sub dvG dvNA by dvG_NA;
  sub dvG dvN dvYA by dvG_N_YA;
  sub dvG dvBA by dvG_BA;
  sub dvG dvBHA by dvG_BHA;
  sub dvG dvBH dvYA by dvG_BH_YA;
  sub dvG dvMA by dvG_MA;
  sub dvG dvYA by dvG_YA;
  sub dvG_R dvYA by dvG_R_YA;
  sub dvG dvLA by dvG_LA;
  sub dvG dvVA by dvG_VA;
  sub dvG dvSA by dvG_SA;

  sub dvGH dvNA by dvGH_NA;
  sub dvGH dvMA by dvGH_MA;
  sub dvGH dvYA by dvGH_YA;

  sub dvC dvCA by dvC_CA;
  sub dvC dvCHA by dvC_CHA;
  sub dvC dvCH dvVA by dvC_CH_VA;
  sub dvC dvNA by dvC_NA;
  sub dvC dvMA by dvC_MA;
  sub dvC dvYA by dvC_YA;

  sub dvCH dvYA by dvCH_YA;
  sub dvCH_R dvYA by dvCH_R_YA;

  sub dvJ dvKA by dvJ_KA;
  sub dvJ dvJA by dvJ_JA;
  sub dvJx dvJxA by dvJx_JxA;
  sub dvJ dvJ_NYA by dvJ_J_NYA;
  sub dvJ dvJ dvYA by dvJ_J_YA;
  sub dvJ dvJ dvVA by dvJ_J_VA;
  sub dvJ dvJHA by dvJ_JHA;
  sub dvJ_NY dvYA by dvJ_NY_YA;
  sub dvJ dvTTA by dvJ_TTA;
  sub dvJ dvDDA by dvJ_DDA;
  sub dvJ dvTA by dvJ_TA;
  sub dvJ dvDA by dvJ_DA;
  sub dvJ dvNA by dvJ_NA;
  sub dvJ dvBA by dvJ_BA;
  sub dvJ dvMA by dvJ_MA;
  sub dvJ dvYA by dvJ_YA;
  sub dvJx dvYA by dvJx_YA;
  sub dvJ dvVA by dvJ_VA;

  sub dvJH dvNA by dvJH_NA;
  sub dvJH dvMA by dvJH_MA;
  sub dvJH dvYA by dvJH_YA;

  sub dvNY dvCA by dvNY_CA;
  sub dvNY dvCHA by dvNY_CHA;
  sub dvNY dvJA by dvNY_JA;
  sub dvNY dvSHA by dvNY_SHA;

  sub dvTT dvTTA by dvTT_TTA;
  sub dvTT dvTTHA by dvTT_TTHA;
  sub dvTT dvYA by dvTT_YA;
  sub dvTT dvVA by dvTT_VA;

  sub dvTTH dvTTHA by dvTTH_TTHA;
  sub dvTTH dvYA by dvTTH_YA;
  sub dvTTH dvVA by dvTTH_VA;

  sub dvDD dvDDA by dvDD_DDA;
  sub dvDD dvDDHA by dvDD_DDHA;
  sub dvDD dvYA by dvDD_YA;
  sub dvDD dvVA by dvDD_VA;

  sub dvDDH dvDDHA by dvDDH_DDHA;
  sub dvDDH dvYA by dvDDH_YA;
  sub dvDDH dvVA by dvDDH_VA;

  sub dvNN dvTTA by dvNN_TTA;
  sub dvNN dvTTHA by dvNN_TTHA;
  sub dvNN dvDDA by dvNN_DDA;
  sub dvNN dvDDHA by dvNN_DDHA;
  sub dvNN dvNNA by dvNN_NNA;
  sub dvNN dvMA by dvNN_MA;
  sub dvNN dvYA by dvNN_YA;
  sub dvNN dvVA by dvNN_VA;

  sub dvT dvKA by dvT_KA;
  sub dvT dvK dvYA by dvT_K_YA;
  sub dvT dvK_RA by dvT_K_RA;
  sub dvT dvK dvVA by dvT_K_VA;
  sub dvT dvK_SSA by dvT_K_SSA;
  sub dvT dvKHA by dvT_KHA;
  sub dvT dvKH_RA by dvT_KH_RA;
  sub dvT dvTA by dvT_TA;
  sub dvT dvT dvYA by dvT_T_YA;
  sub dvT dvT dvVA by dvT_T_VA;
  sub dvT dvTHA by dvT_THA;
  sub dvT dvNA by dvT_NA;
  sub dvT dvN dvYA by dvT_N_YA;
  sub dvT dvPA by dvT_PA;
  sub dvT dvP_RA by dvT_P_RA;
  sub dvT dvP dvLA by dvT_P_LA;
  sub dvT dvPHA by dvT_PHA;
  sub dvT dvMA by dvT_MA;
  sub dvT dvM dvYA by dvT_M_YA;
  sub dvT dvYA by dvT_YA;
  sub dvT_R dvYA by dvT_R_YA;
  sub dvT dvLA by dvT_LA;
  sub dvT dvVA by dvT_VA;
  sub dvT dvSA by dvT_SA;
  sub dvT dvS dvNA by dvT_S_NA;
  sub dvT dvS dvYA by dvT_S_YA;
  sub dvT dvS dvVA by dvT_S_VA;

  sub dvTH dvNA by dvTH_NA;
  sub dvTH dvYA by dvTH_YA;
  sub dvTH dvVA by dvTH_VA;

  sub dvD dvGA by dvD_GA;
  sub dvD dvG_RA by dvD_G_RA;
  sub dvD dvGHA by dvD_GHA;
  sub dvD dvDA by dvD_DA;
  sub dvD dvDHA by dvD_DHA;
  sub dvD dvNA by dvD_NA;
  sub dvD dvBA by dvD_BA;
  sub dvD dvB_RA by dvD_B_RA;
  sub dvD dvBHA by dvD_BHA;
  sub dvD dvMA by dvD_MA;
  sub dvD dvYA by dvD_YA;
  sub dvD dvVA by dvD_VA;

  sub dvDH dvNA by dvDH_NA;
  sub dvDH dvN dvYA by dvDH_N_YA;
  sub dvDH dvMA by dvDH_MA;
  sub dvDH dvYA by dvDH_YA;
  sub dvDH dvVA by dvDH_VA;

  sub dvN dvKA by dvN_KA;
  sub dvN dvK dvSA by dvN_K_SA;
  sub dvN dvCA by dvN_CA;
  sub dvN dvCHA by dvN_CHA;
  sub dvN dvTTA by dvN_TTA;
  sub dvN dvDDA by dvN_DDA;
  sub dvN dvTA by dvN_TA;
  sub dvN dvT dvYA by dvN_T_YA;
  sub dvN dvT_RA by dvN_T_RA;
  sub dvN dvT dvSA by dvN_T_SA;
  sub dvN dvTHA by dvN_THA;
  sub dvN dvTH dvYA by dvN_TH_YA;
  sub dvN dvTH dvVA by dvN_TH_VA;
  sub dvN dvDA by dvN_DA;
  sub dvN dvD_RA by dvN_D_RA;
  sub dvN dvD dvVA by dvN_D_VA;
  sub dvN dvDHA by dvN_DHA;
  sub dvN dvDH dvYA by dvN_DH_YA;
  sub dvN dvDH_RA by dvN_DH_RA;
  sub dvN dvDH dvVA by dvN_DH_VA;
  sub dvN dvNA by dvN_NA;
  sub dvN dvN dvYA by dvN_N_YA;
  sub dvN dvPA by dvN_PA;
  sub dvN dvP_RA by dvN_P_RA;
  sub dvN dvPHA by dvN_PHA;
  sub dvN dvPH_RA by dvN_PH_RA;
  sub dvN dvBHA by dvN_BHA;
  sub dvN dvBH dvYA by dvN_BH_YA;
  sub dvN dvBH dvVA by dvN_BH_VA;
  sub dvN dvMA by dvN_MA;
  sub dvN dvM dvYA by dvN_M_YA;
  sub dvN dvYA by dvN_YA;
  sub dvN dvVA by dvN_VA;
  sub dvN dvSA by dvN_SA;
  sub dvN dvS dvTTA by dvN_S_TTA;
  sub dvN dvS dvM dvYA by dvN_S_M_YA;
  sub dvN dvS dvYA by dvN_S_YA;
  sub dvN dvHA by dvN_HA;

  sub dvP dvTTA by dvP_TTA;
  sub dvP dvTTHA by dvP_TTHA;
  sub dvP dvTA by dvP_TA;
  sub dvP dvT dvYA by dvP_T_YA;
  sub dvP dvNA by dvP_NA;
  sub dvP dvPA by dvP_PA;
  sub dvP dvPHA by dvP_PHA;
  sub dvP dvMA by dvP_MA;
  sub dvP dvYA by dvP_YA;
  sub dvP dvLA by dvP_LA;
  sub dvP dvVA by dvP_VA;
  sub dvP dvSA by dvP_SA;

  sub dvPH dvJA by dvPH_JA;
  sub dvPHx dvJxA by dvPHx_JxA;
  sub dvPH dvTTA by dvPH_TTA;
  sub dvPH dvTA by dvPH_TA;
  sub dvPHx dvTA by dvPHx_TA;
  sub dvPH dvNA by dvPH_NA;
  sub dvPH dvPA by dvPH_PA;
  sub dvPH dvPHA by dvPH_PHA;
  sub dvPHx dvPHxA by dvPHx_PHxA;
  sub dvPH dvYA by dvPH_YA;
  sub dvPH dvLA by dvPH_LA;
  sub dvPH dvSHA by dvPH_SHA;
  sub dvPHx dvSA by dvPHx_SA;

  sub dvB dvJA by dvB_JA;
  sub dvB dvJxA by dvB_JxA;
  sub dvB dvJ dvYA by dvB_J_YA;
  sub dvB dvJHA by dvB_JHA;
  sub dvB dvTA by dvB_TA;
  sub dvB dvDA by dvB_DA;
  sub dvB dvDHA by dvB_DHA;
  sub dvB dvDH dvVA by dvB_DH_VA;
  sub dvB dvNA by dvB_NA;
  sub dvB dvBA by dvB_BA;
  sub dvB dvBHA by dvB_BHA;
  sub dvB dvBH_RA by dvB_BH_RA;
  sub dvB dvYA by dvB_YA;
  sub dvB dvLA by dvB_LA;
  sub dvB dvL dvYA by dvB_L_YA;
  sub dvB dvVA by dvB_VA;
  sub dvB dvSHA by dvB_SHA;
  sub dvB dvSA by dvB_SA;

  sub dvBH dvNA by dvBH_NA;
  sub dvBH dvYA by dvBH_YA;
  sub dvBH_R dvYA by dvBH_R_YA;
  sub dvBH dvLA by dvBH_LA;
  sub dvBH dvVA by dvBH_VA;

  sub dvM dvTA by dvM_TA;
  sub dvM dvDA by dvM_DA;
  sub dvM dvNA by dvM_NA;
  sub dvM dvPA by dvM_PA;
  sub dvM dvP_RA by dvM_P_RA;
  sub dvM dvBA by dvM_BA;
  sub dvM dvB dvYA by dvM_B_YA;
  sub dvM dvB_RA by dvM_B_RA;
  sub dvM dvBHA by dvM_BHA;
  sub dvM dvBH dvYA by dvM_BH_YA;
  sub dvM dvBH_RA by dvM_BH_RA;
  sub dvM dvBH dvVA by dvM_BH_VA;
  sub dvM dvMA by dvM_MA;
  sub dvM dvYA by dvM_YA;
  sub dvM dvLA by dvM_LA;
  sub dvM dvVA by dvM_VA;
  sub dvM dvSHA by dvM_SHA;
  sub dvM dvSA by dvM_SA;
  sub dvM dvHA by dvM_HA;

  sub dvY dvNA by dvY_NA;
  sub dvY dvYA by dvY_YA;

  sub dvL dvKA by dvL_KA;
  sub dvL dvK dvYA by dvL_K_YA;
  sub dvL dvKHA by dvL_KHA;
  sub dvL dvGA by dvL_GA;
  sub dvL dvJA by dvL_JA;
  sub dvL dvJxA by dvL_JxA;
  sub dvL dvTTA by dvL_TTA;
  sub dvL dvTTHA by dvL_TTHA;
  sub dvL dvDDA by dvL_DDA;
  sub dvL dvDDHA by dvL_DDHA;
  sub dvL dvTA by dvL_TA;
  sub dvL dvTHA by dvL_THA;
  sub dvL dvTH dvYA by dvL_TH_YA;
  sub dvL dvDA by dvL_DA;
  sub dvL dvD_RA by dvL_D_RA;
  sub dvL dvPA by dvL_PA;
  sub dvL dvPHA by dvL_PHA;
  sub dvL dvBA by dvL_BA;
  sub dvL dvBHA by dvL_BHA;
  sub dvL dvMA by dvL_MA;
  sub dvL dvYA by dvL_YA;
  sub dvL dvLA by dvL_LA;
  sub dvL dvL dvYA by dvL_L_YA;
  sub dvL dvVA by dvL_VA;
  sub dvL dvV dvDDA by dvL_V_DDA;
  sub dvL dvSA by dvL_SA;
  sub dvL dvHA by dvL_HA;

  sub dvV dvNA by dvV_NA;
  sub dvV dvYA by dvV_YA;
  sub dvV dvLA by dvV_LA;
  sub dvV dvVA by dvV_VA;
  sub dvV dvHA by dvV_HA;

  sub dvSH dvKA by dvSH_KA;
  sub dvSH dvKxA by dvSH_KxA;
  sub dvSH dvCA by dvSH_CA;
  sub dvSH dvCHA by dvSH_CHA;
  sub dvSH dvTTA by dvSH_TTA;
  sub dvSH dvTA by dvSH_TA;
  sub dvSH dvNA by dvSH_NA;
  sub dvSH dvMA by dvSH_MA;
  sub dvSH dvYA by dvSH_YA;
  sub dvSH dvLA by dvSH_LA;
  sub dvSH dvVA by dvSH_VA;
  sub dvSH dvSHA by dvSH_SHA;

  sub dvSS dvKA by dvSS_KA;
  sub dvSS dvK_RA by dvSS_K_RA;
  sub dvSS dvTTA by dvSS_TTA;
  sub dvSS dvTT dvYA by dvSS_TT_YA;
  sub dvSS dvTT_RA by dvSS_TT_RA;
  sub dvSS dvTT dvVA by dvSS_TT_VA;
  sub dvSS dvTTHA by dvSS_TTHA;
  sub dvSS dvTTH dvYA by dvSS_TTH_YA;
  sub dvSS dvTTH_RA by dvSS_TTH_RA;
  sub dvSS dvNNA by dvSS_NNA;
  sub dvSS dvNN dvYA by dvSS_NN_YA;
  sub dvSS dvPA by dvSS_PA;
  sub dvSS dvP_RA by dvSS_P_RA;
  sub dvSS dvPHA by dvSS_PHA;
  sub dvSS dvMA by dvSS_MA;
  sub dvSS dvM dvYA by dvSS_M_YA;
  sub dvSS dvYA by dvSS_YA;
  sub dvSS dvVA by dvSS_VA;
  sub dvSS dvSSA by dvSS_SSA;

  sub dvS dvKA by dvS_KA;
  sub dvS dvK_RA by dvS_K_RA;
  sub dvS dvK dvVA by dvS_K_VA;
  sub dvS dvKHA by dvS_KHA;
  sub dvS dvJA by dvS_JA;
  sub dvS dvTTA by dvS_TTA;
  sub dvS dvTA by dvS_TA;
  sub dvS dvT dvYA by dvS_T_YA;
  sub dvS dvT_RA by dvS_T_RA;
  sub dvS dvT dvVA by dvS_T_VA;
  sub dvS dvTHA by dvS_THA;
  sub dvS dvTH dvYA by dvS_TH_YA;
  sub dvS dvDA by dvS_DA;
  sub dvS dvNA by dvS_NA;
  sub dvS dvPA by dvS_PA;
  sub dvS dvP_RA by dvS_P_RA;
  sub dvS dvPHA by dvS_PHA;
  sub dvS dvBA by dvS_BA;
  sub dvS dvMA by dvS_MA;
  sub dvS dvM dvYA by dvS_M_YA;
  sub dvS dvYA by dvS_YA;
  sub dvS dvLA by dvS_LA;
  sub dvS dvVA by dvS_VA;
  sub dvS dvSA by dvS_SA;

  sub dvH dvNNA by dvH_NNA;
  sub dvH dvNA by dvH_NA;
  sub dvH dvMA by dvH_MA;
  sub dvH dvYA by dvH_YA;
  sub dvH dvLA by dvH_LA;
  sub dvH dvVA by dvH_VA;

  sub dvLL dvYA by dvLL_YA;

  # MATRA I

  include (pres_mI.fea);

} pres;


# -----------------------
# Above-base Substitution
# -----------------------

feature abvs {

  # MATRA VOCALIC LIQUIDS (VOCALIC R/RR/L/LL)

  lookup abvs_RA_mvLiquid {
    sub
      dvRA'
      lookup RA_to_vLiquid
      @mvLiquids'
      lookup mvLiquid_to_Reph;
  } abvs_RA_mvLiquid;

  # INDEPENDENT VOWEL

  sub dvII dvAnusvara by dvII_Anusvara;

  # MATRA + REPH + SYLLABLE-MODIFIER:

  # 1. REPH + SYLLABLE-MODIFIER
  sub dvReph dvAnusvara by dvReph_Anusvara;

  # 2. MATRA + REPH
  sub dvmII      dvReph by dvmII_Reph;
  sub dvmE       dvReph by dvmE_Reph;
  sub dvmAI      dvReph by dvmAI_Reph;
  sub dvmO       dvReph by dvmO_Reph;
  sub dvmAU      dvReph by dvmAU_Reph;
# sub dvmEcandra dvReph by dvmEcandra_Reph;
# sub dvmOcandra dvReph by dvmOcandra_Reph;

  # 3. MATRA + SYLLABLE-MODIFIER
  sub dvmII      dvAnusvara by dvmII_Anusvara;
  sub dvmE       dvAnusvara by dvmE_Anusvara;
  sub dvmAI      dvAnusvara by dvmAI_Anusvara;
  sub dvmO       dvAnusvara by dvmO_Anusvara;
  sub dvmAU      dvAnusvara by dvmAU_Anusvara;
  sub dvmEcandra dvAnusvara by dvmEcandra_Anusvara;
  sub dvmOcandra dvAnusvara by dvmOcandra_Anusvara;

  # 4. MATRA + REPH + SYLLABLE-MODIFIER
  sub dvmII      dvReph dvAnusvara by dvmII_Reph_Anusvara;
  sub dvmE       dvReph dvAnusvara by dvmE_Reph_Anusvara;
  sub dvmAI      dvReph dvAnusvara by dvmAI_Reph_Anusvara;
  sub dvmO       dvReph dvAnusvara by dvmO_Reph_Anusvara;
  sub dvmAU      dvReph dvAnusvara by dvmAU_Reph_Anusvara;
# sub dvmEcandra dvReph dvAnusvara by dvmEcandra_Reph_Anusvara;
# sub dvmOcandra dvReph dvAnusvara by dvmOcandra_Reph_Anusvara;

  # MATRA I

  sub
    @mI_ALTS # Only substitute Reph and Syllable Modifier for substituted mI.
    @mI_BASES
    [
      dvReph
      dvAnusvara
      dvReph_Anusvara
    ]'
  by
    [
      dvReph.amI
      dvAnusvara.amI
      dvReph_Anusvara.amI
    ];

} abvs;


# -----------------------
# Below-base Substitution
# -----------------------

feature blws {

  sub dvRA dvmU  by dvRA_mU;
  sub dvRA dvmUU by dvRA_mUU;
  sub dvHA dvmU  by dvHA_mU;
  sub dvHA dvmUU by dvHA_mUU;

  sub dvDA  dvmvR by dvDA_mvR;
  sub dvSHA dvmvR by dvSHA_mvR;
  sub dvHA  dvmvR by dvHA_mvR;

} blws;


# ----------------------
# Post-base Substitution
# ----------------------

feature psts {

  # MATRA II

  sub
    @mII_BASES
    [
      dvmII
      dvmII_Reph
      dvmII_Anusvara
      dvmII_Reph_Anusvara
    ]'
  by
    [
      dvmII.aLong
      dvmII_Reph.aLong
      dvmII_Anusvara.aLong
      dvmII_Reph_Anusvara.aLong
    ];

} psts;


# -----------
# Halant Form
# -----------

feature haln {

  sub dvNGA  dvVirama by dvNG;
  sub dvTTA  dvVirama by dvTT;
  sub dvTTHA dvVirama by dvTTH;
  sub dvDDA  dvVirama by dvDD;
  sub dvDDHA dvVirama by dvDDH;
  sub dvDA   dvVirama by dvD;
  sub dvHA   dvVirama by dvH;

  sub dvRA  dvVirama by dvR;

  sub  dvNG_RA dvVirama by dvNG_R;
  sub  dvTT_RA dvVirama by dvTT_R;
  sub dvTTH_RA dvVirama by dvTTH_R;
  sub  dvDD_RA dvVirama by dvDD_R;
  sub dvDDH_RA dvVirama by dvDDH_R;
  sub   dvD_RA dvVirama by dvD_R;
  sub   dvH_RA dvVirama by dvH_R;

} haln;


# ---------------------
# Contextual Alternates
# ---------------------

# feature calt {
# } calt;


# -------
# Kerning
# -------

# feature kern {
#   include (kern.fea);
# } kern;


# ---------
# Distances
# ---------

# feature dist {
# } dist;


# ------------------------------------------
# Above-base and Below-base Mark Positioning
# ------------------------------------------

include (markclasses.fea);

feature abvm {
  include (abvm.fea);
} abvm;

feature blwm {
  include (blwm.fea);
} blwm;


# ------------------
# Standard Ligatures
# ------------------

feature liga {
  sub f i by fi;
  sub f l by fl;
  sub f f by ff; # I added these
  sub f f i by ffi;
  sub f f l by ffl;
} liga;
